﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IURIP;
using System.Xml;
using URIP.Tool;

namespace URIP.Factory
{
    /// <summary>
    /// Factory to create a pipeline component template
    /// </summary>
    public class PipelineComponentTemplateFactory
    {
        static PipelineComponentTemplateFactory()
        {
            InitPipelineComponentTemplates();
        }
        /// <summary>
        /// The pipeline component template defined in the system
        /// </summary>
        private static Dictionary<string, Type> m_pipelineComponentTemplates = new Dictionary<string, Type>();

        /// <summary>
        /// Initialize all default pipeline component template into a container.
        /// </summary>
        private static void InitPipelineComponentTemplates()
        {
            //@@ add all default pipeline component template here
        }
        /// <summary>
        /// Get a specified pipeline component template from the setting
        /// </summary>
        /// <param name="node"></param>
        /// <param name="target"></param>
        /// <param name="parentTemplate"></param>
        /// <returns></returns>
        public static IPipelineComponentTemplate GetPipelineComponentTemplate(XmlNode node, ITarget target, ITemplate parentTemplate)
        {
            var res = Util.GetObjectForFactory<IPipelineComponentTemplate>(m_pipelineComponentTemplates, node, target, parentTemplate);
            if (res != null)
            {
                res.InitByConfiguration(node);
            }
            return res;
        }
    }
}
